<template>
  <div>
    <Menu :menus="menus"></Menu>
    <input type="text" @change="testChange">
  </div>

</template>
<script>
  import Menu from '@/components/Menu'
  export default {
    name: "Number",
    components:{Menu},
    data(){
      return {
        selected:0,
        message:function (val,funct) {
            if(typeof funct === "function"){
                funct.call(this);
            }
          return  this.a = val;
        },
        menus:["jsaa","html","css"]
      }
    },
    mounted(){
      this.message("hello world",function(){
          console.log(this.a=20);
      });
      return;
      var arr=[
        {name:"a"},
        {name:"b"},
        {name:"c"},
        {name:"b"},
        {name:"b"},
        {name:"a"},
        {name:"a"},
        {name:"b"}
      ];
      console.log(arr.sort((a,b)=>a.name>b.name));
return;
      var arr=[{name:"lly"},{name:"luy"}];
      var a2 = [5, 10, 6, 7, 8],
        a1 = [1, 2, 3, 4, 5, 6];

//      增
//      从数组尾增加一个元素
      a2.push(10);
      console.log(a2);
//      从数组头增加一个元素
      a2.unshift(10);
      console.log(a2);
//      从数组指定位置插入一个元素
      a2.splice(1, 0, 2)


//      删
      a2.pop();
//      删除指定元素
      console.log(a2);
//      改
//      查
      a2.forEach(function (item, index) {
        console.log(item, index);
      })

//      取交集
      var b1 = [1, 2, 3, 4],
        b2 = [2, 5, 4, 10];
      var b = b2.concat(b1),
        newArray = [];
      for (var i = 0; i < b.length; i++) {
        if (b.indexOf(b[i]) != b.lastIndexOf(b[i])) {
          if (newArray.includes(b[i]) == false) {
            newArray[newArray.length] = b[i];
          }
        }
      }
      console.log(b);
      console.log(newArray);
//      取叉集
      var c1 = [1, 2, 3, 4],
        c2 = [2, 5, 4, 10];
      var c = c2.concat(c1),
        newArray2 = [];
      for (var i = 0; i < c.length; i++) {
        if (c.indexOf(c[i]) == c.lastIndexOf(c[i])) {
          newArray2[newArray2.length] = c[i];
        }
      }
      console.log(c);
      console.log(newArray2);
      var d1=[{name:"lyly"},{name:"lulu"}];
      d1.forEach(function (item) {
        console.log(item.name);
      })



    },
    methods:{
      testChange:function () {
        console.log("change");
      },
      menuHandle:function (idx) {
        console.log(idx);
        this.selected = idx;
      }
    }
  }

</script>
<style scoped>
</style>
